#include <alibabacloud/oss/OssClient.h>
#include <fstream>
using namespace AlibabaCloud::OSS;

int main(void)
{
    std::string AccessKeyId = "LTAI5t6CJLdHYEP2vAmRa7PT";
    std::string AccessKeySecret = "BXvRPQBYm8w7DGuJuzjRibKUpIR4eT";
    std::string Endpoint = "oss-cn-hangzhou.aliyuncs.com";
    std::string BucketName = "bucket-lwh-test";
    std::string ObjectName = "oss/2.txt";

    InitializeSdk();

    ClientConfiguration conf;
    OssClient client(Endpoint, AccessKeyId, AccessKeySecret, conf);
    std::shared_ptr<std::iostream> content = std::make_shared<std::fstream>("./2.txt", std::ios::in | std::ios::binary);
    PutObjectRequest request(BucketName, ObjectName, content);

    auto outcome = client.PutObject(request);

    if (!outcome.isSuccess()) {
        /* 异常处理。*/
        std::cout << "PutObject fail" <<
        ",code:" << outcome.error().Code() <<
        ",message:" << outcome.error().Message() <<
        ",requestId:" << outcome.error().RequestId() << std::endl;
        return -1;
    }
    ShutdownSdk();
    return 0;
}
